﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

using DBLayer;
using ModelLayer;
using WcfTicketsLibrary;

namespace WcfTicketsLibrary
{
    // NOTE: You can use the "Rename"command on the "Refactor" menu to change the class name "ShowServices" in both code and config file together.
    public class ShowService : IShow
    {


        public ShowRoom GetShowRoomOnShowId(int showId)
        {
            ShowRoom room = new DBShowRoom().GetShowRoomOnShowId(showId);
            return room;
        }


        public ShowType GetTypeOnShowId(int showId)
        {
            ShowType type = new DBShowType().GetTypeOnShowId(showId);
            return type;
        }

        public List<Price> GetPrice(int showId)
        {
            List<Price> priceList = new List<Price>();
            priceList = new DBPrice().GetPrice(showId);

            return priceList;
        }

        public Show GetShow(int showId)
        {
            ShowRoom room = GetShowRoomOnShowId(showId);
            ShowType type = GetTypeOnShowId(showId);
            List<Price> prices = GetPrice(showId);

            return AssembleShow(room, type, prices, showId);
        }

        //
        private Show AssembleShow(ShowRoom room, ShowType type, List<Price> price, int showId)
        {
            Show show = new DBShow().AssembleShow(room, type, price, showId);
            return show;
        }

        public List<Show> GetShowsByDate(DateTime date)
        {
            List<Show> shows = new DBShow().GetShowsByDate(date);//get a list of shows that only has date assigned in the show object

            List<Show> compShows = new List<Show>();

            for (int i = 0; i <= shows.Count() - 1; i++)
            {
                Show s = shows[i];
                int showId = s.ShowId;

                s = GetShow(showId);

                compShows.Add(s);
            }
            return compShows;
        }

        //private ShowRoom AddSeatsToShowRoom(ShowRoom room)
        //{
        //    //TODO: Fix!
        //    //SeatService seatService = new SeatService();
        //    //room.Seats.AddRange(seatService.GetAllSeats());
        //    return room;
        //}
    }
}
